<pre>
<tt>
<font color="#FF0000">/**	\author    coidgen 0.7.4</font>
<font color="#FF0000">	\version    (0.0 build 1)</font>
<font color="#FF0000">	\date      </font>
<font color="#FF0000">	\brief     </font>
<font color="#FF0000">*/</font>

<font color="#000080">#ifndef</font> __COID_CLIENT__example_h
<font color="#000080">#define</font> __COID_CLIENT__example_h


<font color="#000080">#define</font> CLIENT__example_h



<font color="#000080">#include</font> <font color="#000000">"coid/coidclient/coidclient.h"</font>
<font color="#000080">#include</font> <font color="#000000">"coid/comm/sync/mutex_reg.h"</font>


<font color="#0000FF">extern</font> <font color="#0000FF">const</font> version COID_version_example_0_0;


<font color="#FF0000">///Example struct used for argument in methods</font>
<font color="#0000FF">struct</font> FOO_STRUCT
<font color="#000080">{</font>
    <font color="#0000FF">charstr</font> message;
    <font color="#0000FF">int</font> * array;
    <font color="#0000FF">int</font> size;

    <font color="#000000">FOO_STRUCT(</font>) : <font color="#000000">array(</font>NULL), <font color="#000000">size(</font><font color="#00D000">0</font>) <font color="#000080">{</font><font color="#000080">}</font>

    FOO_STRUCT &amp; <font color="#0000FF">operator</font> = ( <font color="#0000FF">const</font> FOO_STRUCT &amp; x ) <font color="#000080">{</font>
        message = x.message; size = x.size;
        <font color="#0000FF">if</font>( array ) <font color="#000080">{</font><font color="#0000FF">delete</font> array; array = NULL;<font color="#000080">}</font>
        <font color="#0000FF">if</font>( size ) <font color="#000080">{</font>
            array = <font color="#0000FF">new</font> <font color="#0000FF">int</font>[size];
            <font color="#000000">memcpy(</font> array, x.array, size * <font color="#0000FF">sizeof</font>(<font color="#0000FF">int</font> *) );
        <font color="#000080">}</font>
        <font color="#0000FF">return</font> *<font color="#0000FF">this</font>;
    <font color="#000080">}</font>
    
    <font color="#FF0000">///write object to stream</font>
    <font color="#0000FF">friend</font> binstream &amp; <font color="#0000FF">operator</font> &lt;&lt; ( binstream &amp; b, <font color="#0000FF">const</font> FOO_STRUCT &amp; x ) <font color="#000080">{</font>
        b &lt;&lt; x.message &lt;&lt; x.size;
        <font color="#0000FF">if</font>( x.size ) b.<font color="#000000">write_raw(</font> x.array, x.size * <font color="#0000FF">sizeof</font>(<font color="#0000FF">int</font> *) );
        <font color="#0000FF">return</font> b;
    <font color="#000080">}</font>
    
    <font color="#FF0000">///read object from stream</font>
    <font color="#0000FF">friend</font> binstream &amp; <font color="#0000FF">operator</font> &gt;&gt; ( binstream &amp; b, FOO_STRUCT &amp; x ) <font color="#000080">{</font>
        b &gt;&gt; x.message &gt;&gt; x.size;
        <font color="#0000FF">if</font>( x.array ) <font color="#000080">{</font><font color="#0000FF">delete</font> x.array; x.array = NULL;<font color="#000080">}</font>
        <font color="#0000FF">if</font>( x.size ) <font color="#000080">{</font>
            x.array = <font color="#0000FF">new</font> <font color="#0000FF">int</font>[x.size];
            b.<font color="#000000">read_raw(</font> x.array, x.size * <font color="#0000FF">sizeof</font>(<font color="#0000FF">int</font> *) );
        <font color="#000080">}</font>
        <font color="#0000FF">return</font> b;
    <font color="#000080">}</font>
<font color="#000080">}</font>;

<font color="#FF0000">///Structure for remapping example, client side</font>
<font color="#0000FF">struct</font> REMAP_EXAMPLE_clientside
<font color="#000080">{</font>
    <font color="#0000FF">charstr</font> err_text;
    <font color="#0000FF">friend</font> binstream &amp; <font color="#0000FF">operator</font> &gt;&gt; ( binstream &amp; b, REMAP_EXAMPLE_clientside &amp; x ) <font color="#000080">{</font>
        x.err_text.<font color="#000000">reset(</font>);
        <font color="#0000FF">int</font> tmp;
        b &gt;&gt; tmp;
        <font color="#0000FF">if</font>( tmp ) <font color="#000080">{</font>
            <font color="#0000FF">char</font> * str = x.err_text.<font color="#000000">get_append_buf(</font> tmp+<font color="#00D000">1</font> );
            b.<font color="#000000">read_raw(</font> str, tmp );
            str[tmp] = <font color="#00D000">0</font>;
        <font color="#000080">}</font>
        <font color="#0000FF">return</font> b;
    <font color="#000080">}</font>
<font color="#000080">}</font>;




<font color="#0000FF">namespace</font> coid <font color="#000080">{</font>


<font color="#0000FF">struct</font> COID_TABLE_example_0_0;


<font color="#FF0000">///Example decorated class</font>
<font color="#0000FF">class</font> example_client
<font color="#000080">{</font>
<font color="#0000FF">private</font>:
	COID_TABLE_example_0_0 * _me;
	COID_TABLE_example_0_0 * _vtbl;
	<font color="#0000FF">mutable</font> comm_mutex_custom_reg&lt;netstream, <font color="#0000FF">void</font>*&gt; _mx_reg;
	<font color="#0000FF">mutable</font> mexestream _mexestream;
	<font color="#0000FF">uint</font> _conn_data;
	<font color="#0000FF">charstr</font> _addr;

	<font color="#0000FF">void</font> <font color="#000000">set_connection_type(</font> <font color="#0000FF">uint</font> ct ) <font color="#000080">{</font>_conn_data = ct;<font color="#000080">}</font>
	<font color="#0000FF">void</font> <font color="#000000">destroy_me(</font>);

<font color="#0000FF">public</font>:
	<font color="#000000">example_client(</font>);
	~<font color="#000000">example_client(</font>);
	<font color="#000000">example_client(</font> <font color="#0000FF">const</font> example_client &amp; c );
	example_client &amp; <font color="#0000FF">operator</font> = ( <font color="#0000FF">const</font> example_client &amp; c );

	<font color="#0000FF">bool</font> <font color="#000000">is_connected(</font>) <font color="#0000FF">const</font> <font color="#000080">{</font><font color="#0000FF">return</font> _me != NULL;<font color="#000080">}</font>
	<font color="#0000FF">opcd</font> <font color="#000000">disconnect(</font>);
	<font color="#0000FF">const</font> <font color="#0000FF">char</font> * <font color="#000000">get_addr(</font>) <font color="#0000FF">const</font> <font color="#000080">{</font><font color="#0000FF">return</font> _addr;<font color="#000080">}</font>
	comm_mutex_reg * <font color="#000000">get_mx(</font>) <font color="#000080">{</font><font color="#0000FF">return</font> &amp;_mx_reg;<font color="#000080">}</font>
	<font color="#0000FF">opcd</font> <font color="#000000">get_last_error(</font>) <font color="#0000FF">const</font>;
	<font color="#0000FF">void</font> <font color="#000000">set_last_error(</font> <font color="#0000FF">opcd</font> e );
	<font color="#0000FF">uint</font> <font color="#000000">get_connection_type(</font>) <font color="#0000FF">const</font> <font color="#000080">{</font><font color="#0000FF">return</font> _conn_data;<font color="#000080">}</font>
	<font color="#0000FF">void</font> <font color="#000000">setup_stream(</font> binstream &amp; b, <font color="#0000FF">uint</font> coid_flags, <font color="#0000FF">uint</font> coid_obj_id );
	<font color="#0000FF">bool</font> <font color="#000000">setup_members(</font> <font color="#0000FF">uint</font> coid_stream_flags, netstream * bstream, binstream * bstream2=NULL, comm_mutex_reg * mx_reg=NULL );

	<font color="#0000FF">static</font> <font color="#0000FF">const</font> version &amp; <font color="#000000">get_version(</font>) <font color="#000080">{</font> <font color="#0000FF">return</font> COID_version_example_0_0; <font color="#000080">}</font>


<font color="#0000FF">public</font>:
	<font color="#0000FF">opcd</font> <font color="#000000">connect(</font>  <font color="#0000FF">const</font> <font color="#0000FF">charstr</font> &amp; name, <font color="#0000FF">const</font> password &amp; pwd, <font color="#0000FF">const</font> <font color="#0000FF">char</font> * coid_address=NULL, <font color="#0000FF">uint</font> coid_flags=ConnectFlags::xACCESS_MODE );
	<font color="#0000FF">opcd</font> <font color="#000000">connect_within(</font>  comm_mutex_reg &amp; coid_channel, <font color="#0000FF">const</font> <font color="#0000FF">charstr</font> &amp; name, <font color="#0000FF">const</font> password &amp; pwd );
	<font color="#0000FF">opcd</font> <font color="#000000">connect_shared(</font> <font color="#0000FF">uint</font> coid_obj_id,  <font color="#0000FF">const</font> <font color="#0000FF">char</font> * coid_address=NULL, <font color="#0000FF">uint</font> coid_flags=ConnectFlags::xACCESS_MODE  );

	<font color="#FF0000">//user functions</font>
	<font color="#0000FF">opcd</font> <font color="#000000">read1(</font> FOO_STRUCT &amp; list );
	<font color="#0000FF">opcd</font> <font color="#000000">read2(</font> FOO_STRUCT &amp; list );
	<font color="#0000FF">opcd</font> <font color="#000000">send(</font> <font color="#0000FF">int</font> &amp; ref, <font color="#0000FF">const</font> <font color="#0000FF">charstr</font> &amp; command, binstreambuf &amp; reply ) <font color="#0000FF">const</font>;
	<font color="#0000FF">opcd</font> <font color="#000000">remap_fnc(</font> REMAP_EXAMPLE_clientside &amp; remapped_arg );
	<font color="#FF0000">//method available only in direct (client&amp;server in the same process) mode</font>
	<font color="#0000FF">opcd</font> <font color="#000000">get_ptr(</font> FOO_STRUCT ** f );
<font color="#000080">}</font>;

<font color="#000080">}</font> <font color="#FF0000">// namespace coid</font>


<font color="#000080">#endif</font>	<font color="#FF0000">// ! __COID_CLIENT__example_h</font>
</tt>
</pre>
